#define _CRT_SECURE_NO_WARNINGS  1
#pragma warning(disable:6031)
#include <stdio.h>
#include <stdlib.h>

int main()
{
	char ch = 0;
	int n = 0;
	int i = 0;
	int j = 0;

	scanf("%d", &n);
	while ((ch = getchar()) != '\n')
	{
		;
	}

	char* password = (char*)calloc(n, 100 * sizeof(char));
	for (i = 0; i < n; i++)
	{
		j = 0;
		while ((*(password + 100 * i + j) = getchar()) != '\n')
		{
			j++;
		}
	}

	int len = 0;
	int kinds = 0;
	int kind[3] = { 0 };
	int flag = 0;
	for (i = 0; i < n; i++)
	{
		flag = 0;
		kinds = 0;
		len = 0;
		kind[0] = 0;
		kind[1] = 0;
		kind[2] = 0;
		if (*(password + 100 * i + 0) >= '0' &&
			*(password + 100 * i + 0) <= '9')
		{
			flag = 1;
			goto conclude;
		}
		for (j = 0; j < 100 && *(password + 100 * i + j) != '\n'; j++)
		{
			if (*(password + 100 * i + j) >= '0' &&
				*(password + 100 * i + j) <= '9')
			{
				len++;
				if (kind[kinds] == 0)
				{
					kind[kinds] = 1;
					kinds++;
				}
			}
			else if (*(password + 100 * i + j) >= 'a'
				&& *(password + 100 * i + j) <= 'z')
			{
				len++;
				if (kind[kinds] == 0)
				{
					kind[kinds] = 1;
					kinds++;
				}
			}
			else if (*(password + 100 * i + j) >= 'A'
				&& *(password + 100 * i + j) <= 'Z')
			{
				len++;
				if (kind[kinds] == 0)
				{
					kind[kinds] = 1;
					kinds++;
				}
			}
			else
			{
				flag = 1;
				goto conclude;
			}
		}
	conclude:
		if (flag || len < 8 || kinds < 2)
		{
			printf("NO\n");
		}
		else
		{
			printf("YES\n");
		}

	}
	return 0;
}